/*
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2, or (at your option)
 * any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 * 02111-1307, USA.
 *
 * http://www.gnu.org/copyleft/gpl.html
 */
package l1j.jrwz.server.model.trap;

import l1j.jrwz.server.model.L1Object;
import l1j.jrwz.server.model.Instance.L1PcInstance;
import l1j.jrwz.server.model.poison.L1DamagePoison;
import l1j.jrwz.server.model.poison.L1ParalysisPoison;
import l1j.jrwz.server.model.poison.L1SilencePoison;
import l1j.jrwz.server.storage.TrapStorage;

public class L1PoisonTrap extends L1Trap {
    private final String _type;
    private final int _delay;
    private final int _time;
    private final int _damage;

    public L1PoisonTrap(TrapStorage storage) {
        super(storage);

        _type = storage.getString("poisonType");
        _delay = storage.getInt("poisonDelay");
        _time = storage.getInt("poisonTime");
        _damage = storage.getInt("poisonDamage");
    }

    @Override
    public void onTrod(L1PcInstance trodFrom, L1Object trapObj) {
        sendEffect(trapObj);

        if (_type.equals("d")) {
            L1DamagePoison.doInfection(trodFrom, trodFrom, _time, _damage);
        } else if (_type.equals("s")) {
            L1SilencePoison.doInfection(trodFrom);
        } else if (_type.equals("p")) {
            L1ParalysisPoison.doInfection(trodFrom, _delay, _time);
        }
    }
}
